#include <stdio.h>
#include <string.h>

int bulle_sort(int nums[], int length){
  for(int i = 0; i < length -1; i++){
    for(int j = 0; j < length - i - 1; j++){
      if(nums[j] > nums[j+1]){
        int tmp = nums[j];
        nums[j] = nums[j+1];
        nums[j+1] = tmp;
      }
    }
  }
}

void print_array(int array[], int length){
  for(int i = 0; i < length; i++){
    printf("%d ", array[i]);
  }
  printf("\n");
}


int main(int argc, char* argv[])
{
  FILE *rfp;
  char str[80];
  int nums[100];
  if((rfp = fopen(argv[1], "r")) == NULL){
    printf("文件打开失败!\n");
    return -1;
  }
  int length = 0;
  while(fgets(str, 80, rfp) != NULL){
    sscanf(str, "%d", &nums[length]);
    length++;
  }
  bulle_sort(nums, length);
  print_array(nums, length);
  fclose(rfp);
  return 0;
}
